import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    db_activity:[
             {
   
              startDateTime: "2020/1/1 00:00",
              endDateTime: "2020/1/20 00:00",
              activityName: "元旦开春特惠",
              activityId:"0001",
              detail: "北京市暂不参与活动",
              gift: null,
              range: "全场通用",
              postImg: "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fpic165.nipic.com%2Ffile%2F20180517%2F22131647_163352235000_2.jpg&refer=http%3A%2F%2Fpic165.nipic.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1635247019&t=618ac1139c7ceb44a41ca9fa8d283c0d",
              type: "限时降价",
              discount: 1000,
        },
        {
    
          startDateTime: "2020/10/1 00:00",
          endDateTime: "2020/10/20 00:00",
          activityName: "国庆特惠",
          activityId:"0002",
          detail: "杭州市、宁波市专属活动",
          gift: "小米扫地机器人一台",
          range: "全场通用",
          postImg: "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fpic165.nipic.com%2Ffile%2F20180517%2F22131647_163352235000_2.jpg&refer=http%3A%2F%2Fpic165.nipic.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1635247019&t=618ac1139c7ceb44a41ca9fa8d283c0d",
          type: "限时赠礼",
          discount: 0,
    },
    ],
    db_coupon:[ {
      id: "0001",
      issuer:'平台',
      type: "免费券",
      startDate: "2021/4/10 08:00",
      endDate: "2021/4/10 08:00",
      count:100,
      price:0,
      discount:1000,
      threshold:20000
    },
    {
      id: "0002",
      issuer:'平台',
      type: "有价代金券",
      startDate: "2021/4/10 08:00",
      endDate: "2021/5/10 08:00",
      count:10,
      price:100,
      discount:2000,
      threshold:20000
    },
     {
      id: "0003",
      issuer:'平台',
      type: "有价代金券",
      startDate: "2021/9/25 08:00",
      endDate: "2021/10/10 08:00",
      count:"无限",
      price:1,
      discount:100,
      threshold:10000
    },],
    db_shop:[],
    db_adv:[
      {
        id: '0001',
        img:"https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fhbimg.b0.upaiyun.com%2F6d1991b936040f2ff078d97131960bfdce37c2416abc3-Ory2Wc_fw658&refer=http%3A%2F%2Fhbimg.b0.upaiyun.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1635158813&t=5d20a7326df5e81867a03b0b57f60bd3",
        issuer: "浙房产",
        propertyname: "浙商房产",
        startDate:"2020/8/12 08:00",
        endDate:"2020/8/12 08:00"
      },
      {
        id: '0002',
        img:"https://gimg2.baidu.com/image_search/src=http%3A%2F%2Ftuddimgs.oss-cn-hangzhou.aliyuncs.com%2F202002%2FDesign006_dCY8Hj7NNQ.jpg%3Fx-oss-process%3Dstyle%2Fprev_w_750_h_auto&refer=http%3A%2F%2Ftuddimgs.oss-cn-hangzhou.aliyuncs.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1635159612&t=312aa397d815fa210480a5060cdaf088",
        issuer: "浙里帮卖",
        propertyname: "浙商房产",
        startDate:"2020/8/12 08:00",
        endDate:"2020/8/12 08:00"
      },
    ],
    db_park:[
      {
        propertyIndex:'0001',
        propertyName:"翠微小区",
        parkId:'A001',
      }
    ]
  },
  mutations: {
    delete_coupon(state,id){
      console.log(state.db_coupon)
      for(let i in state.db_coupon){

        if(state.db_coupon[i].id==id){
          state.db_coupon.splice(i,1)
        }
      }
    },
    delete_activity(state,id){
      console.log(state.db_activity)
      for(let i in state.db_activity){

        if(state.db_activity[i].id==id){
          state.db_activity.splice(i,1)
        }
      }
    },
    del_db_adv(state,id){
      console.log(state.db_adv)
      for(let i in state.db_adv){

        if(state.db_adv[i].id==id){
          state.db_adv.splice(i,1)
        }
      }
    },
    insert_db_coupon(state,item){
      state.db_coupon.push(item)
    },
    insert_db_park(state,item){
      state.db_park.push(item)
    },
    init_db_shop(state,arr){
      state.db_shop.splice(0,state.db_shop.length)
      for(let i of arr){
        state.db_shop.push(i)
      }
    },
    insert_db_adv(state,adv){
      if(state.db_adv.length==0){
        adv.id = 0
        state.db_adv.push(adv)
      }else{
        adv.id = state.db_adv[state.db_adv.length-1].id+1
        state.db_adv.push(adv)
      }
    },

    init_db_adv(state,arr){
      state.db_adv.splice(0,state.db_adv.length)
      for(let adv of arr){
        if(state.db_adv.length==0){
          adv.id = 0
          state.db_adv.push(adv)
        }else{
          adv.id = state.db_adv[state.db_adv.length-1].id+1
          state.db_adv.push(adv)
        }
      }
    }
  },
  actions: {
  },
  modules: {
  }
})
